package com.emily.test.service.impl;

import com.emily.test.service.EmailService;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.mail.SimpleMailMessage;
import org.springframework.mail.javamail.JavaMailSender;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

/**
 * @author ：zc
 * @date ：Created in 2019/4/2 13:38
 * @description：
 */
@Service
public class EmailServiceImpl implements EmailService {
    @Resource
    JavaMailSender jms;
    @Override
    public String send(String sender, String receiver, String title, String text) {
        //建立邮件消息
        SimpleMailMessage mainMessage = new SimpleMailMessage();
        //发送者
        mainMessage.setFrom(sender);
        //接收者
        mainMessage.setTo(receiver);
        //发送的标题
        mainMessage.setSubject(title);
        //发送的内容
        mainMessage.setText(text);
        jms.send(mainMessage);
        return "1";
    }

}
